package com.tool4j.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tool4j.entity.Feedback;
import com.tool4j.mapper.FeedbackMapper;
import com.tool4j.service.FeedbackService;
import com.tool4j.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {

    @Autowired
    private FeedbackMapper feedbackMapper;

    @Autowired
    private MailService mailService;

    @Override
    public void saveData(Feedback params) {
        String content = """
                主题：%s
                反馈类型：%s
                内容：%s
                联系方式：%s
                """.formatted(params.getTitle(), params.getType(), params.getContent(), params.getContact());
        mailService.sendMail("tool4j@163.com", "【Tool4j】--意见反馈", content);
        feedbackMapper.insert(params);
    }
}
